{include file="index/_meta" /}
    <title>店铺信息</title>
</head>
<body>
<div id="app">
    <van-nav-bar
            title="店铺信息"
            left-text="返回"
            left-arrow
            @click-left="window.history.back();"
    ></van-nav-bar>

    <van-form @submit="onSubmit">
        <van-field
                v-model="form.name"
                name="name"
                label="店铺名称"
                placeholder=""
                :rules="[{ required: true, message: '请填写用户名' }]"
        ></van-field>
        <van-field
                v-model="form.phone"
                name="phone"
                label="联系电话"
                placeholder=""
                :rules="[{ required: true, message: '请填写用户名' }]"
        ></van-field>

        <van-field name="state" label="店铺状态">
            <template #input>
                <van-radio-group v-model="form.state" direction="horizontal">
                    <van-radio name="10">营业</van-radio>
                    <van-radio name="20">暂时歇业</van-radio>
                </van-radio-group>
            </template>
        </van-field>

        <div style="margin: 16px;">
            <van-button round block type="info" native-type="submit">
                提交
            </van-button>
        </div>
    </van-form>

</div>
<script>
    new Vue({
        el: "#app",
        data(){return{
            form:{},
            showArea: false,
            areaList: {},
            area_code: '',
        }},
        created(){
            this.getDetail()
        },
        methods:{

            onSubmit(values) {
                console.log('submit', values);
                let that = this
                axios.post("{:url('store/shopEdit')}",that.form).then(function (res) {
                    let ret = res.data
                    console.log(ret)
                    if(ret.code == 0){
                        vant.Notify({type:'success',message:ret.msg,duration:1000})
                    }else{
                        vant.Notify({type:'danger',message:ret.msg,duration:1000})
                    }
                })
            },
            getDetail() {
                let that = this
                let user = JSON.parse(localStorage.getItem('user'));
                axios.post("{:url('store/getShopDetail')}",{shop_id: "{$Think.session.wechat.shop_id}"}).then(function (res) {
                    let ret = res.data
                    that.form = ret.data
                    that.goods = ret.data.goods
                    that.isLoading = false
                }).catch(function () {
                    vant.Dialog.alert({
                        message: '当前店铺不存在或已下架，请点击返回首页重新选择店铺',
                        confirmButtonText:"返回首页"
                    }).then(() => {
                        window.location.href = "{:url('index/index')}"
                    });
                })
            },
        },
    })
</script>
</body>
</html>
